﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using Database;

namespace DT5_Anh09110006_Hung09110044_Vu09110157.QuanLy
{
    public partial class QuanLyDangKiCho : System.Web.UI.Page
    {
        Business.QuanLyDangKi qlDK = new Business.QuanLyDangKi();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                LoadDuLieu();
            }
        }
        public void LoadDuLieu()
        {
            grvHV_DK.DataSource = qlDK.LayDanhSach();
            grvHV_DK.DataBind();
        }
        protected void grvHV_DK_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if(e.CommandName.Equals("Xoa")){
                if(qlDK.XoaDangKi(Convert.ToInt64(e.CommandArgument)))
                {

                }
                else{
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Thông báo !", "alert('Không thể xóa học viên này');", true);
                }
                LoadDuLieu();
            }
        }

        protected void grvHV_DK_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grvHV_DK.PageIndex = e.NewPageIndex;
            LoadDuLieu();
        }
    }
}